package reflect;

import java.io.File;
import java.lang.reflect.Field;

public class ReflectDemo8 {
    public static void main(String[] args) throws Exception {
        Class cls=Class.forName("reflect.Teacher");
        Object obj=cls.newInstance();

        Field f= cls.getDeclaredField("name");
        f.set(obj,"张三");
        System.out.println(obj);

        Field f1= cls.getDeclaredField("age");
        f1.set(obj,18);
        System.out.println(obj);
    }
}
